<script>
	export default {
		onLaunch: function() {
			var token=uni.getStorageSync('Authorization');
			
			var that=this;
			
			if(token){
				this.$request({
					url:'/login/checkLogin',
					success:(res)=>{
						if(res.data.code==1){
							var data=res.data.data;
							
							var info=data.info;
							
							var token=data.token;
							
							let openId=data.openId
							
							if(token!=''){
								that.$store.commit('changeLogin',token);
							}
							
							let port = that.$store.state.port
							
							if(port!='android' && port!='ios'){
								
								if( openId){
									that.$store.commit('setOpenid',openId);
								}else{
									that.$store.commit('wx_login')
								}
							}
							
							
							that.$store.commit('getInfo',info);
							
							that.$store.commit('messageSocket')
						}else{
							if(res.data.code==103){
								that.$store.commit('clearToken');
								
								uni.showToast({
								    title: '您的账号已停用',
								    duration: 2000
								});
							}else{
								that.$store.commit('clearToken');
								
								uni.showModal({
								    title: '登录提示',
								    content: '您的登录状态已失效,是否重新登录',
								    success: function (res) {
								        if (res.confirm) {
											uni.reLaunch({
											    url: '/pages/login/login'
											});
								        }
								    }
								});
							}
						}
					},
					fail:(res)=>{
						console.log('网络繁忙');
					}
				})
			}else{
				console.log('未登录')
			}
		},
		onShow: function() {
			console.log('App Show')
		},
		onHide: function() {
			console.log('App Hide')
		}
	}
</script>

<style lang="scss">
	@import "uview-ui/index.scss";
</style>

<style>
	.clear{
		clear:both;
	}
	.loading_view{
	  display: flex;
	  flex-direction: column;
	  justify-content: center;
	  align-items: center;
	  color:#bbb;
	  font-size: 32rpx;
	  margin-top: 20vh;
	 }
	 .loading_view .icon{
		 width: 320rpx;
		 height: 320rpx;
	 }
	 .loading_view .messgae{
	  margin-top: 20rpx;
	 }
	 .loading_view .message_btn{
		 margin-top:30rpx;
	 }
	 .tips_messgae{
		width:750rpx;
		height: 80rpx;
		line-height: 80rpx;
		text-align: center;
		color:#666;
	 }
	 .empty{
	 	padding:20rpx 0;
	 	text-align: center;
	 }
</style>